<template>
  <div id="groupSales">
    <!-- 头部 -->
    <div class="hand">
      <c-title :hide="false" text="团队销售额"></c-title>
      <div class="userinfos">
        <div class="userinfo">
          <div>
            <img :src="avatar_image"></img>
          </div>
          <div style="margin-left: 7px; overflow: hidden;">
            <div class="name ls1">
              {{username||'---'}}
            </div>
            <div class="grade">
              {{agentLevel}}
            </div>
          </div>
        </div>
        <div class="time ls1" @click="changeSlideDown()">
          <div>{{selectedTime == ''?newTime:selectedTime}}</div>
          <div class="iconfont icon-member-bottom" style="margin-left: 3px; font-size: 22px; margin-top: 5px;"></div>
        </div>
        <!-- 时间选择组件-->
        <van-popup v-model="slideDown" position="bottom">
          <van-datetime-picker v-model="currentDate" type="year-month" title="选择年月" :min-date="minDate"
            :max-date="maxDate" :formatter="formatter" @confirm="changeSlideDown" @cancel="cancelTimePopover" />
        </van-popup>
      </div>
    </div>
    <!-- 销售额 -->
    <div class="saleroom ls1">
      <div v-for="(item,index) in sale" :key="index" class="list" :style="index == 0?'':'margin-top:20px'">
        <div>{{index == 0?'我的本月销售额':'我的年度销售额'}}</div>
        <div style="color: #f14e4e;">¥<span>{{item == null?0:item}}</span></div>
      </div>
    </div>
    <!-- 我的团队销售额-->
    <div class="teamSalesEntry ls1">
      <van-cell is-link title="我的团队销售额" @click="goMy_team_sales" />
    </div>
    <!-- 我的销售明细 -->
    <div class="salesParticular">
      <div style="background-color: white;">
        <van-tabs v-model="activeName" title-active-color="#f15353">
          <van-tab title="我的销售明细" name="1"></van-tab>
        </van-tabs>
        <div class="hr"></div>
      </div>
      <div v-for="(item,index) in salesDetail" :key="index" :class="index==0?'firstDetailed':'detailed'" class="list">
        <div class="single">
          <div style="display: flex;">
            <img :src="item.has_one_member && item.has_one_member.avatar_image" />
            <div class="usr">
              <div class="name">{{item.has_one_member && item.has_one_member.username}}</div>
              <div class="id">
                <div>ID:</div>
                <div style="margin-left: 4px;">{{item.uid}}</div>
              </div>
            </div>
          </div>
          <div style="color: #f15353; font-size: 13px;" class="ls1">¥{{item.sales}}</div>
        </div>
        <div style="margin-top: 22px; font-size: 13px;">{{item.has_one_order  && item.has_one_order.order_sn}}</div>
        <div style="margin-top: 12px; display: flex; font-size: 13px;">
          <div>生成时间:</div>
          <div style="margin-left: 10px;">{{item.created_at}}</div>
        </div>
      </div>
      <van-divider v-if="salesDetail.length == 0">{{'暂无数据'}}</van-divider>
      <van-divider v-if="orderLastPage && salesDetail.length != 0" style="margin-bottom: 12px;">{{'暂无更多'}}</van-divider>
      <van-divider v-if="!orderLastPage&& salesDetail.length != 0" style="margin-bottom: 12px;">{{'下拉刷新'}}</van-divider>
    </div>
  </div>
</template>

<script>
  import group_sales_controller from "./group_sales_controller";
  export default group_sales_controller;
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
  .ls1 {
    letter-spacing: 1px;
  }

  #groupSales {
    background-color: #f7f8fb;
    height: 100vh;

    .hand {
      color: white;
      background-color: #ff8924;

      .userinfos {
        margin-top: 20px;
        height: 100px;
        padding-left: 15px;
        padding-right: 15px;
        display: flex;
        align-content: center;
        justify-content: space-between;

        .userinfo {
          display: flex;
          flex: 1;
          overflow: hidden;

          img {
            border-radius: 50px;
            width: 60px;
            height: 60px;
          }

          .name {
            color: white;
            margin-bottom: 13px;
            font-weight: bold !important;
            text-align: left;
            font-size: 16px;
            background-color: transparent;
            overflow: hidden;/* 超出部分隐藏 */
            text-overflow: ellipsis;/* 超出部分显示省略号 */
            white-space: nowrap;/* 规定段落中的文本不进行换行 */
          }

          .grade {
            background-color: white;
            border-radius: 30px;
            padding: 3px 10px 3px 12px;
            color: #ba750c;
            width: fit-content;
            text-align: center;
            font-size: 12px;
          }
        }

        .time {
          display: flex;
          align-items: center;
          height: 50px;
          font-size: 14px;
        }
      }
    }

    .saleroom {
      background-color: white;
      border-radius: 5px;
      height: 80px;
      padding: 10px 18px 10px 18px;
      margin: 10px;
      margin-top: -20px;
      color: #282828;
      font-weight: 550;

      .list {
        display: flex;
        align-content: center;
        justify-content: space-between;
      }
    }

    .teamSalesEntry {
      margin: 10px;
    }

    .salesParticular {
      margin: 10px;
      overflow: hidden;

      .hr {
        width: 330px;
        height: 0.5px;
        background-color: #fffafa;
        margin-left: 10px;
        margin-right: 10px;
      }

      .list {
        background-color: white;
        padding: 10px;
      }

      .single {
        display: flex;
        align-content: center;
        justify-content: space-between;

        .usr {
          margin-left: 7px;
          letter-spacing: 0rpx;
          text-align: left;

          .name {
            font-size: 14px;
            color: #353535;
          }

          .id {
            display: flex;
            color: #686868;
            font-size: 12px;
            // transform: scale(0.7);
            margin-top: 5px;
          }
        }

        img {
          border-radius: 50px;
          width: 30px;
          height: 30px;
        }
      }
    }

    .order {
      margin: 10px;
      background-color: white;
      border-radius: 5px;
    }

    .firstDetailed {
      border-bottom-right-radius: 7px;
      border-bottom-left-radius: 7px;
    }

    .detailed {
      border-radius: 7px;
      margin-top: 10px;
    }

    div {
      text-align: left;
    }

    ::v-deep .van-cell--clickable {
      font-weight: bold;
      text-align: left;
    }

    ::v-deep .van-cell {
      border-radius: 5px;
    }

    ::v-deep .van-button--primary {
      border: none;
      background-color: white;
      font-size: 13px;
      width: 100%;
      height: 20px;
      color: black;
      padding-left: 0;
    }

    ::v-deep .van-nav-bar {
      background-color: #ff8924;
      border: none;
    }

    ::v-deep .van-button--default {
      background-color: #ff8924;
    }

    ::v-deep .van-nav-bar__title {
      color: white;
      font-weight: 100;
      font-size: 18px;
    }

    ::v-deep .van-nav-bar .van-icon {
      color: white;
      font-size: 19px;
    }

    ::v-deep .van-tabs__line {
      background-color: #f56c6c;
      height: 2.6px;
      border-radius: 3px;
      bottom: 22px;
    }

    ::v-deep .van-cell__right-icon {
      color: #595959;
    }

    ::v-deep .van-divider {
      font-size: 12px;
    }
  }
</style>
